<?
    class My_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract {
        protected $languages;
        protected $path;
        public function __construct($lang, $p){
            $this->languages = $lang;
            $this->path = $p;
        }
        public function routeShutdown(Zend_Controller_Request_Abstract $request){
            $lang = $request->getParam('language');
			if(!in_array($lang, array_keys($this->languages))) { 
				$lang = 'en'; 
			}
            Zend_Registry::set('lang', $lang);
			$localeString = $this->languages[$lang];
            $zl = new Zend_Locale();            
            $zl->setLocale($localeString);
			// setup translate object
			$file = $this->path . '/../application/translations/'. $lang . '.php';

			if(file_exists($file)) { 
				include $file; 
			} else { 
				include $this->path . '/../application/translations/en.php';
			} 
			if(!isset($translationStrings)) {
				throw new Exception('Missing $translationStrings');
			}
			$translate = new Zend_Translate('array', $translationStrings, $lang);
			//Zend_Registry::set('Zend_Locale', $locale);
            Zend_Registry::set('Zend_Translate', $translate);
            $frontController = Zend_Controller_Front::getInstance();            
            $frontController->getRouter()->setGlobalParam('language', $lang);
          }
      }